package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author fx
 * @since 2024-08-25
 */
@Api(tags = "互动问答-客户端-问题相关接口")
@RestController
@RequestMapping("/questions")
@RequiredArgsConstructor
public class InteractionQuestionController {

    private final IInteractionQuestionService questionService;

    /**
     * 01 新增 互动问题（day05-随堂-01）
     *
     * @param formDTO
     */
    @ApiOperation("新增互动问题")
    @PostMapping
    public void addQuestion(@Valid @RequestBody QuestionFormDTO formDTO) {
        questionService.addQuestion(formDTO);
    }

    /**
     * 02 分页查询 互动问题-客户端（day05-随堂-02）
     *
     * @param pageQuery
     * @return
     */
    @ApiOperation("分页查询互动问题-客户端")
    @GetMapping("/page")
    public PageDTO<QuestionVO> pageQueryQuestions( QuestionPageQuery pageQuery) {
        return questionService.pageQueryQuestions(pageQuery);
    }

    /**
     * 03 根据id查询 互动问题详情（day05-随堂-03）
     * @param id
     * @return
     */
    @ApiOperation("根据id查询互动问题详情")
    @GetMapping("/{id}")
    public QuestionVO queryQuestionById(@PathVariable("id") Long id){
        return questionService.queryQuestionById(id);
    }

    @ApiOperation("删除互动问题")
    @DeleteMapping("/{id}")
    public void deleteQuestionById(Long id){
        questionService.deleteQuestionById(id);
    }






}
